package com.wxapp.admin.service.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxapp.admin.api.pojo.vm.job.PJobDetailVm;
import com.wxapp.admin.api.pojo.vm.job.PJobPageVm;
import com.wxapp.admin.api.pojo.vo.job.QJobPageVo;
import com.wxapp.admin.api.pojo.vo.job.QJobSaveVo;
import com.wxapp.admin.api.pojo.vo.job.QJobUpdateVo;
import com.wxapp.admin.service.service.JobService;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author lgl
 * @Description 岗位管理
 * @Datetime 2022/8/8 17:14
 * @Modified By
 */

@RestController
@RequestMapping("job")
@Tag(name = "岗位管理")
@RequiredArgsConstructor
public class JobController extends IBaseController {

    private final JobService jobService;

    @PostMapping("/save")
    @Operation(summary = "保存岗位信息")
    public ResultVm<String> saveJob(@Schema(hidden = true) @User UserVo userVo, @RequestBody QJobSaveVo qJobSaveVo) {
        return jobService.saveJob(userVo, qJobSaveVo);
    }

    @PutMapping("/update")
    @Operation(summary ="更新岗位信息")
    public ResultVm<String> updateJob(@Schema(hidden = true) @User UserVo userVo, @RequestBody QJobUpdateVo qSaveVo) {
        return jobService.updateJob(userVo, qSaveVo);
    }

    @GetMapping("/detail")
    @Operation(summary ="得到岗位详情")
    public ResultVm<PJobDetailVm> detailJob(@RequestParam String id) {
        return jobService.detailJob(id);
    }

    @PostMapping("/page")
    @Operation(summary ="更新岗位信息")
    public ResultVm<Page<PJobPageVm>> pageJob(@RequestBody QJobPageVo qSaveVo) {
        return jobService.pageJob(qSaveVo);
    }

    @DeleteMapping("/delete/{id}")
    @Operation(summary ="删除岗位")
    public ResultVm<String> deleteJob(@PathVariable String id) {
        return jobService.deleteJob(id);
    }

}
